package com.ruoyi.doorBind.service.impl;

import com.ruoyi.cost.mapper.HouseCostTMapper;
import com.ruoyi.costQuery.domain.HouseCostT;
import com.ruoyi.data.MD5;
import com.ruoyi.doorBind.domain.DoorBindT;
import com.ruoyi.doorBind.mapper.DoorBindTMapper;
import com.ruoyi.doorBind.service.IDoorBindTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 户管理Service业务层处理
 *
 * @author lijie
 * @date 2023-04-20
 */
@Service
public class DoorBindTServiceImpl implements IDoorBindTService {
    @Autowired
    private DoorBindTMapper doorBindTMapper;
    @Autowired
    private HouseCostTMapper houseCostTMapper;

    @Override
    public List<DoorBindT> selectLeftList(DoorBindT doorBindT) {
        return doorBindTMapper.selectLeftList(doorBindT);
    }

    @Override
    public List<DoorBindT> selectRightList(DoorBindT doorBindT) {
        return doorBindTMapper.selectRightList(doorBindT);
    }

    @Override
    public DoorBindT getDoorInfo(DoorBindT doorBindT) {
        return doorBindTMapper.getDoorInfo(doorBindT);
    }

    @Override
    public DoorBindT getDoorBind(DoorBindT doorBindT) {
        return doorBindTMapper.getDoorBind(doorBindT);
    }

    @Override
    @Transactional
    public void updateDoorBindT(DoorBindT doorBindT) throws Exception {


//        doorBindTMapper.updateCostInfo(doorBindT);
        doorBindTMapper.updateDoorBindT(doorBindT);

//        doorBindTMapper.updateDoorInfo(doorBindT);
        doorBindTMapper.insertDoorInfo(doorBindT);

        HouseCostT houseCostT = new HouseCostT();
        int costId = houseCostTMapper.getCostId();
        houseCostT.setSerial(String.valueOf(costId+1));
        houseCostT.setCostDate(doorBindT.getCostDate());
        houseCostT.setCreater(doorBindT.getCreater());
        houseCostT.setHouseId(doorBindT.getHouseId());
        houseCostT.setCostMoney(doorBindT.getCostMoney());
        houseCostTMapper.insertHouseCostT1(houseCostT);
    }

    @Override
    @Transactional
    public void insertDoor(DoorBindT doorBindT) {
        doorBindTMapper.insertDoor(doorBindT);
    }


}
